import type HttpRequest from '@candy/framework/http/HttpRequest';
import Application from '@candy/framework/rest/Application';
import Main from '@candy/framework';
import HttpResponse from '@candy/framework/http/HttpResponse';

const app = new Application({
    'id': 'rest',
    'debug': true,
});

app.get('/', async (_request: HttpRequest) => {
    return HttpResponse.fromText('Hello');
});

app.get('/user/{id}', async (_request: HttpRequest, params: any) => {
    const userId = params.id;
    return HttpResponse.fromJson({
        data: {
            id: userId,
        },
    });
});

new Main(app).listen({
    port: 2333,
});
